<template>
  <ul class="todo-list">
    <!-- completed: 完成的类名 -->
    <li :class="{completed:item.done==true}"  v-for="item in ShowList" :key="item.id">
      <div class="view">
        <input class="toggle" type="checkbox" v-model="item.done"/>
        <label>{{item.value}}</label>
        <button class="destroy" @click="del(item.id)"></button>
      </div>
    </li>
  </ul>
  
</template>

<script>
import { mapGetters } from 'vuex'
export default {
data() {
  return {
    done: false
  }
},

methods: {
    del(id) {
      const index = this.TodoMain.findIndex(item => item.id == id)
      const list = this.TodoMain
      list.splice(index, 1)
      this.$store.commit('TodoMain/setTodoMainList',list)
   
    }
  },
computed: {
    ...mapGetters(['TodoMain', 'TodoList', 'DoneList','ShowList']),
},
 watch: {
    TodoMain:{
    deep: true,
      handler(val) {
        this.$store.commit('TodoMain/setTodoMainList',val)
      },
   }
  }
}
</script>
